package spelet;

import java.applet.AudioClip;
import java.net.URL;
import java.net.MalformedURLException;

public class Sound {

    SoundList soundList;
    AudioClip onceClip;
    URL codeBase;

    public Sound() {
        try {
            codeBase = new URL("file:" + System.getProperty("user.dir") + "/sounds/");
            // Håller URL:en för där alla filer ligger

        } catch (MalformedURLException e) {
            System.err.println(e.getMessage());
        }
        soundList = new SoundList(codeBase);

    }

    public void Load(String loadSound) {
        soundList.startLoading(loadSound);
    }

    public void Play(String playSound) {
        onceClip = soundList.getClip(playSound);
        onceClip.play();
    }

    public void Loop(String loopSound){
           onceClip = soundList.getClip(loopSound);
            onceClip.loop();

    }
    public void Stop(String stopSound) {
        onceClip = soundList.getClip(stopSound);
        onceClip.stop();
    }

}
